using Gtk;
using Gdk;

namespace Meridian.Content {
	
	public class TabLabel : HBox {
		
		private Gtk.Image icon;
		private Label label;
		public Button close_button;
		
		public TabLabel (string title, Gtk.Image default_icon) {
		    this.icon = default_icon;
		
			//new label
			this.label = new Label (title);
			
			//new close_button
			this.close_button = new Button ();
			var image = new Gtk.Image.from_stock(Stock.CLOSE, IconSize.BUTTON);
			image.set_padding (0, 0);
			
			close_button.set_image (image);
			
			//set style
			var rc_style = new RcStyle ();
			rc_style.xthickness = 0;
			rc_style.ythickness = 0;
			close_button.modify_style (rc_style);
			close_button.set_relief (ReliefStyle.NONE);

			this.pack_start (this.close_button);
			this.pack_start (this.label);
			this.pack_start (this.icon);
			
			this.show_all ();
		}
		
		public void set_title (string title) {
			this.label.set_text (title);
			this.show_all ();
		}
		
		public void set_icon (Pixbuf pixbuf) {
			this.icon.set_from_pixbuf (pixbuf);
			this.show_all ();
		}
		
		public string get_title () {
			return this.label.get_text ();
		}
		
		public Button get_close_button () {
			return this.close_button;
		}
	}
}
